﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WebApi.DAL
{
    public static class UsersDAL
    {
        public static IEnumerable<User> GetAllUsers()
        {
            WebApiDBDataContext db = new WebApiDBDataContext();
            //var users =
            //    (from user in db.Users
            //    select new User
            //    {
            //        ID = user.ID,
            //        FirstName = user.FirstName,
            //        LastName = user.LastName,
            //        UserName = user.UserName
            //    }).ToList<User>();

            var users = db.Users;
            return users;
        }

        public static User GetUser(int id)
        {
            WebApiDBDataContext db = new WebApiDBDataContext();
            var searchingUser =
                (from user in db.Users
                 where user.ID == id
                 select user).FirstOrDefault();
            return searchingUser;
        }
    }
}
